import { defineStore } from "pinia";
import API from "../axios";

// 获取最新歌曲
export const getNewSongStore = defineStore('getNewSongStore', {
    state: () => {
        return {
            res: null,
        }
    },
    actions: {
        fetch: (url: string) => {
            return API.getNewSongAPI(url)
        }
    }
})

// 获取推荐歌单
export const getresourceStore = defineStore('getresourceStore', {
    state: () => {
        return {
            res: null,
        }
    },
    actions: {
        fetch: (limit: string | number) => {
            return API.getresourceAPI(limit)
        }
    }
})

// 获取热门明星
export const getStartStore = defineStore('getStartStore', {
    state: () => {
        return {
            res: null,
        }
    },
    actions: {
        fetch: (url: string) => {
            return API.getStartAPI(url)
        }
    }
})
// 对手机发送验证码
export const getCodeStore = defineStore('getCodeStore', {
    state: () => {
        return {
            res: null,
        }
    },
    actions: {
        fetch: (phone: number | undefined) => {
            return API.getCodeAPI(phone)
        }
    }
})
//验证验证码拿到登陆状态
export const captchaCodeStore = defineStore('captchaCodeStore', {
    state: () => {
        return {
            res: null,
        }
    },
    actions: {
        fetch: (phone: number | undefined, code: any) => {
            return API.captchaCodeAPI(phone, code)
        }
    }
})
//拿到登陆状态
export const getLoginStore = defineStore('getLoginStore', {
    state: () => {
        return {
            cookie: null,
            data: null
        }
    },
    actions: {
        getCookie(val: any) {
            this.cookie = val
        },
        getUseData(val: any) {
            this.data = val
        }
    }
})

//获取相应分类中的歌单
export const playlistStore = defineStore('playlistStore', {
    state: () => {
        return {
            res: null,
        }
    },
    actions: {
        fetch: (cat: string) => {
            return API.playlistAPI(cat)
        }
    }
})
//获取全部分类
export const getPlaylistClassilyStor = defineStore('getPlaylistClassilyStor', {
    state: () => {
        return {
            res: null
            // sub:API.playlistClassilyAPI,
        }
    },
    actions: {
        fetch: (url: string) => {
            return API.playlistClassilyAPI(url)
        }
    }

})
// 获取最新MV
export const newMvStore = defineStore('newMvStore', {
    state: () => {
        return {
            res: null
        }
    },
    actions: {
        fetch: (val: number) => {
            return API.newMvAPI(val)
        }
    }
})
// 获取最新MV
export const WYMvStore = defineStore('WYMvStore', {
    state: () => {
        return {
            res: null
        }
    },
    actions: {
        fetch: (val: number) => {
            return API.WYMvAPI(val)
        }
    }
})
//获取推荐MV
export const personalizedMvStore = defineStore('personalizedMvStore', {
    state: () => {
        return {
            res: null
        }
    },
    actions: {
        fetch: (val: any) => {
            return API.personalizedMvAPI(val)
        }
    }
})
//获取MV详情
export const mvDetailStore = defineStore('mvDetailStore', {
    state: () => {
        return {
            res: null
        }
    },
    actions: {
        fetch: (id: any) => {
            return API.mvDetailsAPI(id)
        }
    }
})
//获取MV地址
export const VideoUrlStore = defineStore('VideoUrlStore', {
    state: () => {
        return {
            res: null
        }
    },
    actions: {
        fetch: (id: any) => {
            return API.VideoUrlAPI(id)
        }
    }
})
//获取相似MV地址
export const simiMvStore = defineStore('simiMvStore', {
    state: () => {
        return {
            res: null
        }
    },
    actions: {
        fetch: (id: any) => {
            return API.simiMvAPI(id)
        }
    }
})
// 获取歌单详情地址
export const songSheetStore = defineStore('songSheetStore',{
    state:() =>{
        return{
            res:null,
        }
    },
    actions:{
        fetch:(songSheetId:number,cookie:string | null) =>{
            return API.songSheetAPI(songSheetId,cookie)
        }
    }
})
// 获取歌单所有歌曲
export const AllsongSheetStore = defineStore('AllsongSheetStore',{
    state:() =>{
        return{
            res:null,
        }
    },
    actions:{
        fetch:(songSheetId:number,cookie:string | null) =>{
            return API.AllsongSheetAPI(songSheetId,cookie)
        }
    }
})

